{include file='common/head'}
<style>
    .imgs{width:80px;height: 100px;margin-left:10px}
</style>
<body>
<div class="x-body">
    <form class="layui-form" method="post"  enctype="multipart/form-data" action="">
        <input type="hidden" name="uid" value="{$arr.uid}">
        <div class="layui-form-item">
            <label class="layui-form-label">主营产品</label>
            <div class="layui-input-inline">
                <input type="text" name="product" placeholder="请输入要补充的内容" autocomplete="off" class="layui-input" value="{$arr.product}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">基本信息</label>
            <div class="layui-input-inline">
                <input type="text" name="information" placeholder="请输入要补充的内容" autocomplete="off" class="layui-input" value="{$arr.information}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">交付能力</label>
            <div class="layui-input-inline">
                <input type="text" name="ability" placeholder="请输入要补充的内容" autocomplete="off" class="layui-input" value="{$arr.ability}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">公司介绍</label>
            <div class="layui-input-inline">
                <input type="text" name="introduce" placeholder="请输入要补充的内容" autocomplete="off" class="layui-input" value="{$arr.introduce}">
            </div>
        </div>
        <div  class="layui-form-item">
            <label class="layui-form-label">公司能力</label>
            <div>
                {volist name='ability' id='ability' key='key'}
                <input type="checkbox" name='name[]' title="{$ability.ability}"  value="{$ability.aid}" {if in_array($ability['aid'],$aid)} checked{else}{/if}>
                {/volist}
            </div>
        </div>
        <!--//厂房外景-->
        <div class="layui-upload">
            <button type="button" class="layui-btn" id="cover1">厂房外景</button>
            <div class="layui-input-inline" id="preview1" name="img1">
                <?php for($i=0;$i<count($location_img);$i++){ ?>
                <img src="/upload/news/{$location_img[$i]}" class="imgs">
                <a title="删除" onclick="member_del1(this,'{$arr.uid},{$i}')" href="javascript:;">
                    <i class="layui-icon">&#xe640;</i>
                </a>
                <?php } ?>
                <input type="hidden" name="location_img" value="{$arr.location_img}" >
                <input type="hidden" id="location_imgs" value="" name="location_imgs">
            </div>
        </div>
        <!--//办公场所-->
        <div class="layui-upload">
            <button type="button" class="layui-btn" id="cover2">办公场所</button>
            <div class="layui-input-inline" id="preview2" name="img2">
                <?php for($i=0;$i<count($place_img);$i++){ ?>
                <img src="/upload/newsclass="imgs"/{$place_img[$i]}" class="imgs">
                <a title="删除" onclick="member_del2(this,'{$arr.uid},{$i}')" href="javascript:;">
                    <i class="layui-icon">&#xe640;</i>
                </a>
                <?php } ?>
                <input type="hidden" name="place_img" value="{$arr.place_img}" >
                <input type="hidden" id="place_imgs" value="" name="place_imgs">
            </div>
        </div>
        <!--//常规设备-->
        <div class="layui-upload">
            <button type="button" class="layui-btn" id="cover3">常规设备</button>
            <div class="layui-input-inline" id="preview3" name="img3">
                <?php for($i=0;$i<count($equipment_img);$i++){ ?>
                <img src="/upload/news/{$equipment_img[$i]}" class="imgs">
                <a title="删除" onclick="member_del3(this,'{$arr.uid},{$i}')" href="javascript:;">
                    <i class="layui-icon">&#xe640;</i>
                </a>
                <?php } ?>
                <input type="hidden" name="equipment_img" value="{$arr.equipment_img}" >
                <input type="hidden" id="equipment_imgs" value="" name="equipment_imgs">
            </div>
        </div>
        <!--//营业执照-->
        <div class="layui-upload">
            <button type="button" class="layui-btn" id="cover4">营业执照</button>
            <div class="layui-input-inline" id="preview4" name="img4">
                <?php for($i=0;$i<count($license_img);$i++){ ?>
                <img src="/upload/news/{$license_img[$i]}" class="imgs">
                <a title="删除" onclick="member_del4(this,'{$arr.uid},{$i}')" href="javascript:;">
                    <i class="layui-icon">&#xe640;</i>
                </a>
                <?php } ?>
                <input type="hidden" name="license_img" value="{$arr.license_img}" >
                <input type="hidden" id="license_imgs" value="" name="license_imgs">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="sub" lay-submit="" >
                发布
            </button>
        </div>
    </form>
</div>
<script src="__STATIC__/lib/layui/layui.js"></script>
<script src="__STATIC__/js/jquery-3.3.1.min.js"></script>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;
        //监听提交
        form.on('submit(sub)', function(data){
            $.ajax({
                type: "post",
                async:false,
                url: "{:url('index/black/xiugai')}",
                data: data.field,
                success:function(msg){
                    if(msg==1){
                        layer.msg(msg.msg,{icon:1,time:2000});
                        //发异步，把数据提交给php
                        layer.alert("补充成功", {icon: 6},function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                        });
                        window.parent.location.reload();//刷新父级窗口
                    }else{
                        layer.msg(msg.msg,{icon:1,time:1000});
                    }
                }
            })
            return false;
        });
    });
</script>
<script>
    //厂房外景
    layui.use('upload', function() {
        var upload = layui.upload;
        var $ = layui.jquery;
        var uploadInst = upload.render({
            elem:'#cover1'
            ,url:'{:url("index/black/doUpload")}'
            ,multiple: 'true'
            ,accept:'images'  // 允许上传的文件类型
            ,auto:true // 自动上传
            ,before:function (obj) {
                // 预览
                obj.preview(function(index,file,result) {
                    // console.log(file.name);    //图片名字
                    // console.log(file.type);    //图片格式
                    // console.log(file.size);    //图片大小
                    // console.log(result);       //图片地址
                    $('#preview1').append('<img src="' + result + '" alt="' + file.name +
                        '" class="layui-upload-img" style="width:80px;height: 80px;margin-left:10px">');
                });
                // layer.load();
            }
            // 上传成功回调
            ,done:function(res) {
                if (res.code == 1) {
                    $('#location_imgs').val($('#location_imgs').val()+res.url);//将上传的图片路径输出存入数组，传值
                    return layer.msg(res.msg);
                }
                return layer.msg(res.msg);
            }
            // 上传失败回调
            ,error:function(index,upload) {
                return layer.msg(res.msg);
            }
        });
    });
    function member_del1(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //layer.msg('已删除!',{icon:1,time:1000});
            var uid=id;
            //alert(uid);
            var uid=uid.split(',');
            var mid=uid['0'];
            var urlimg=uid['1'];
            $.ajax({
                url: "{:url('index/black/location_img')}",
                type: "post",
                dataType: "JSON",
                data: {uid: mid,urlimg:urlimg},
                success: function (res) {
                    if (res==1) {
                        layer.msg('删除成功！');
                        setTimeout(function () {
                            location.reload();
                        }, 1000);
                        return false;
                    } else {
                        layer.msg('删除失败！');
                        return false;
                    }
                }
            });
        });
    }
    //常规设备
    layui.use('upload', function() {
        var upload = layui.upload;
        var $ = layui.jquery;
        var uploadInst = upload.render({
            elem:'#cover3'
            ,url:'{:url("index/black/doUpload")}'
            ,multiple: 'true'
            ,accept:'images'  // 允许上传的文件类型
            ,auto:true // 自动上传
            ,before:function (obj) {
                // 预览
                obj.preview(function(index,file,result) {
                    // console.log(file.name);    //图片名字
                    // console.log(file.type);    //图片格式
                    // console.log(file.size);    //图片大小
                    // console.log(result);       //图片地址
                    $('#preview3').append('<img src="' + result + '" alt="' + file.name +
                        '" class="layui-upload-img" style="width:80px;height: 80px;margin-left:10px">');
                });
                // layer.load();
            }
            // 上传成功回调
            ,done:function(res) {
                if (res.code == 1) {
                    $('#equipment_imgs').val($('#equipment_imgs').val()+res.url);//将上传的图片路径输出存入数组，传值
                    return layer.msg(res.msg);
                }
                return layer.msg(res.msg);
            }
            // 上传失败回调
            ,error:function(index,upload) {
                return layer.msg(res.msg);
            }
        });
    });
    function member_del3(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //layer.msg('已删除!',{icon:1,time:1000});
            var uid=id;
            //alert(uid);
            var uid=uid.split(',');
            var mid=uid['0'];
            var urlimg=uid['1'];
            $.ajax({
                url: "{:url('index/black/equipment_img')}",
                type: "post",
                dataType: "JSON",
                data: {uid: mid,urlimg:urlimg},
                success: function (res) {
                    if (res==1) {
                        layer.msg('删除成功！');
                        setTimeout(function () {
                            location.reload();
                        }, 1000);
                        return false;
                    } else {
                        layer.msg('删除失败！');
                        return false;
                    }
                }
            });
        });
    }
    //办公场所
    layui.use('upload', function() {
        var upload = layui.upload;
        var $ = layui.jquery;
        var uploadInst = upload.render({
            elem:'#cover2'
            ,url:'{:url("index/black/doUpload")}'
            ,multiple: 'true'
            ,accept:'images'  // 允许上传的文件类型
            ,auto:true // 自动上传
            ,before:function (obj) {
                // 预览
                obj.preview(function(index,file,result) {
                    // console.log(file.name);    //图片名字
                    // console.log(file.type);    //图片格式
                    // console.log(file.size);    //图片大小
                    // console.log(result);       //图片地址
                    $('#preview2').append('<img src="' + result + '" alt="' + file.name +
                        '" class="layui-upload-img" style="width:80px;height: 80px;margin-left:10px">');
                });
                // layer.load();
            }
            // 上传成功回调
            ,done:function(res) {
                if (res.code == 1) {
                    $('#place_imgs').val($('#place_imgs').val()+res.url);//将上传的图片路径输出存入数组，传值
                    return layer.msg(res.msg);
                }
                return layer.msg(res.msg);
            }
            // 上传失败回调
            ,error:function(index,upload) {
                return layer.msg(res.msg);
            }
        });
    });
    function member_del2(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //layer.msg('已删除!',{icon:1,time:1000});
            var uid=id;
            //alert(uid);
            var uid=uid.split(',');
            var mid=uid['0'];
            var urlimg=uid['1'];
            $.ajax({
                url: "{:url('index/black/place_img')}",
                type: "post",
                dataType: "JSON",
                data: {uid: mid,urlimg:urlimg},
                success: function (res) {
                    if (res==1) {
                        layer.msg('删除成功！');
                        setTimeout(function () {
                            location.reload();
                        }, 1000);
                        return false;
                    } else {
                        layer.msg('删除失败！');
                        return false;
                    }
                }
            });
        });
    }
    //营业执照
    layui.use('upload', function() {
        var upload = layui.upload;
        var $ = layui.jquery;
        var uploadInst = upload.render({
            elem:'#cover4'
            ,url:'{:url("index/black/doUpload")}'
            ,multiple: 'true'
            ,accept:'images'  // 允许上传的文件类型
            ,auto:true // 自动上传
            ,before:function (obj) {
                // 预览
                obj.preview(function(index,file,result) {
                    // console.log(file.name);    //图片名字
                    // console.log(file.type);    //图片格式
                    // console.log(file.size);    //图片大小
                    // console.log(result);       //图片地址
                    $('#preview4').append('<img src="' + result + '" alt="' + file.name +
                        '" class="layui-upload-img" style="width:80px;height: 80px;margin-left:10px">');
                });
                // layer.load();
            }
            // 上传成功回调
            ,done:function(res) {
                if (res.code == 1) {
                    $('#license_imgs').val($('#license_imgs').val()+res.url);//将上传的图片路径输出存入数组，传值
                    return layer.msg(res.msg);
                }
                return layer.msg(res.msg);
            }
            // 上传失败回调
            ,error:function(index,upload) {
                return layer.msg(res.msg);
            }
        });
    });
    function member_del4(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //layer.msg('已删除!',{icon:1,time:1000});
            var uid=id;
            //alert(uid);
            var uid=uid.split(',');
            var mid=uid['0'];
            var urlimg=uid['1'];
            $.ajax({
                url: "{:url('index/black/license_img')}",
                type: "post",
                dataType: "JSON",
                data: {uid: mid,urlimg:urlimg},
                success: function (res) {
                    if (res==1) {
                        layer.msg('删除成功！');
                        setTimeout(function () {
                            location.reload();
                        }, 1000);
                        return false;
                    } else {
                        layer.msg('删除失败！');
                        return false;
                    }
                }
            });
        });
    }
</script>

</body>

</html>